<template>
  <div class="app-container">
    <el-row :gutter="20">
      <!-- 约束条件配置面板 -->
      <el-col :span="6">
        <constraint-config-panel 
          v-model="constraintWeights"
          @change="handleConstraintsChange"
          @submit="saveConstraintWeights"
        />
      </el-col>

      <!-- 课表可视化区域 -->
      <el-col :span="18">
        <schedule-chart 
          :schedule-data="scheduleData"
          :conflicts="detectedConflicts"
          @cell-click="handleCellClick"
        />
      </el-col>
    </el-row>
  </div>
</template>

<script>
// import { saveConstraints } from '@/api/motr/scheduling'; // API已删除

export default {
  components: {
    ConstraintConfigPanel: () => import('@/components/ConstraintConfigPanel'),
    ScheduleChart: () => import('@/components/ScheduleChart')
  },
  data() {
    return {
      constraintWeights: {
        teacherPreference: 50,
        classroomCapacity: 80,
        courseConflict: 100
        // 其他约束条件...
      },
      scheduleData: [],
      detectedConflicts: [],
      currentSemester: '2024-2025-1' // 当前学期，实际应用中可能需要从其他地方获取
    }
  },
  methods: {
    handleConstraintsChange(weights) {
      // 更新约束条件权重逻辑
    },
    handleCellClick(cellData) {
      // 处理课表单元格点击事件
    },
    saveConstraintWeights(weights) {
      // 确保传入学期信息
      const constraintData = {
        ...weights,
        semester: this.currentSemester
      };
      
      // TODO: 重新实现约束条件保存功能
      console.log('约束条件数据:', constraintData);
      this.$modal.msgWarning('约束条件保存功能暂时不可用');
    }
  }
}
</script>